VERSION 5.00
Begin VB.Form frmRAS 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Connecting to %s..."
   ClientHeight    =   1125
   ClientLeft      =   2415
   ClientTop       =   3765
   ClientWidth     =   5025
   Icon            =   "RAS.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   1125
   ScaleWidth      =   5025
   Begin VB.CommandButton cmdCancel 
      Cancel          =   -1  'True
      Caption         =   "&Cancel"
      Height          =   375
      Left            =   3720
      TabIndex        =   1
      Top             =   120
      Width           =   1215
   End
   Begin VB.Timer tmrRAS 
      Enabled         =   0   'False
      Interval        =   500
      Left            =   120
      Top             =   600
   End
   Begin VB.Label lblDialAttempt 
      Height          =   255
      Left            =   720
      TabIndex        =   3
      Top             =   120
      Width           =   2775
   End
   Begin VB.Label lblStatus 
      Caption         =   "Status:"
      Height          =   255
      Left            =   720
      TabIndex        =   2
      Top             =   360
      Width           =   495
   End
   Begin VB.Image imgConnect 
      Height          =   480
      Left            =   120
      MouseIcon       =   "RAS.frx":0442
      Picture         =   "RAS.frx":0884
      Top             =   120
      Width           =   480
   End
   Begin VB.Label lblCallStatus 
      Height          =   615
      Left            =   1320
      TabIndex        =   0
      Top             =   360
      Width           =   2175
      WordWrap        =   -1  'True
   End
End
Attribute VB_Name = "frmRAS"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'*---------------------------------------------------------------
'*
'* FormName:       frmRAS
'* FileName:       RAS.FRM
'* Date:           July 1998
'* Author:         Ian M. Weatherburn
'* Company:        Mindkey Software Solutions (Pty) Ltd.
'* Copyright:      Copyright (C) 1998 by Mindkey Software Solutions
'*                 All Rights Reserved
'* Description:    Connection Progress Dialog
'*
'*---------------------------------------------------------------

Option Explicit

Private hRASConn As Long

Private Sub cmdCancel_Click()
  Dim lngRetCode As Integer

  lngRetCode = RasHangUp(hRASConn)
  
  blnCancelConnection = True
  
  Unload Me
End Sub

Private Sub Form_Activate()
  ' Display an hourglass/pointer cursor
  Screen.MousePointer = vbArrowHourglass
  
  frmRAS.Caption = "Connecting to " & strCurrentEntryName & "..."
  
  ' Maintain the RAS server handle
  ' This is the other half of the KLUDGE
  ' I get hRASConn from the TAG that I set before I loaded the form
  hRASConn = "&H" & frmRAS.Tag
  
  ' Set the asynchronous timer going
  tmrRAS.Enabled = True
End Sub

Private Sub Form_Unload(Cancel As Integer)

  ' Stop the asynchronous timer
  tmrRAS.Enabled = False
  
  ' Restore the mouse cursor
  Screen.MousePointer = vbDefault

End Sub

Private Sub tmrRAS_Timer()
  Dim lngRetCode As Long
  Dim lngRASConnState As Long
  Dim lngRASError As Long
  
  If lngWindowVersion = VER_PLATFORM_WIN32_NT Then
    ' We are using Windows NT
    Dim lpRASConnStatus As RASConnStatus
    lpRASConnStatus.dwSize = 64
    
    lngRetCode = RasGetConnectStatus(hRASConn, lpRASConnStatus)
    
    If lngRetCode Then
      lngRASErrorNumber = lngRetCode
      lblCallStatus.Caption = lpRASError.fnRASErrorMessage()
      lngRetCode = RasHangUp(hRASConn)
      tmrRAS.Enabled = False
      lngRASError = 10000
    Else
      lngRASConnState = lpRASConnStatus.RASConnState
      lngRASError = lpRASConnStatus.dwError
    End If
  Else
    ' We are using Windows 95
    Dim lpRASConnStatus95 As RASConnStatus95
    lpRASConnStatus95.dwSize = 160
    
    lngRetCode = RasGetConnectStatus(hRASConn, lpRASConnStatus95)
    
    If lngRetCode Then
      lngRASErrorNumber = lngRetCode
      lblCallStatus.Caption = lpRASError.fnRASErrorMessage()
      lngRetCode = RasHangUp(hRASConn)
      tmrRAS.Enabled = False
      lngRASError = 10000
    Else
      lngRASConnState = lpRASConnStatus95.RASConnState
      lngRASError = lpRASConnStatus95.dwError
    End If
  End If
  
  ' If an error occured then raise it
  ' else update the Call Status text with the appropiate information
  Select Case lngRASError
    Case RAS_SUCCESS, PENDING
      Select Case lngRASConnState
        Case RASCS_OpenPort
          lblCallStatus.Caption = "Attempting to Open Port..."
        Case RASCS_PortOpened
          lblCallStatus.Caption = "Port Successfully Opened."
        Case RASCS_ConnectDevice
          lblCallStatus.Caption = "Attempting to Connect Device..."
        Case RASCS_DeviceConnected
          lblCallStatus.Caption = "Dialling..."
        Case RASCS_AllDevicesConnected
          lblCallStatus.Caption = "All Devices Connected."
        Case RASCS_Authenticate
          lblCallStatus.Caption = "Verifying User Name and Password..."
        Case RASCS_AuthNotify
          lblCallStatus.Caption = "Authentification Notification."
        Case RASCS_AuthRetry
          lblCallStatus.Caption = "Retrying Authentication..."
        Case RASCS_AuthCallback
          lblCallStatus.Caption = "Authentication Callback."
        Case RASCS_AuthChangePassword
          lblCallStatus.Caption = "Change Password."
        Case RASCS_AuthProject
          lblCallStatus.Caption = "Authenticating Project..."
        Case RASCS_AuthLinkSpeed
          lblCallStatus.Caption = "Authenticating Link Speed..."
        Case RASCS_AuthAck
          lblCallStatus.Caption = "Authentication Acknowledgment."
        Case RASCS_ReAuthenticate
          lblCallStatus.Caption = "ReAuthentication..."
        Case RASCS_Authenticated
          lblCallStatus.Caption = "User name and password verified..."
        Case RASCS_PrepareForCallback
          lblCallStatus.Caption = "Preparing for Callback..."
        Case RASCS_WaitForModemReset
          lblCallStatus.Caption = "Waiting for Modem Reset..."
        Case RASCS_WaitForCallback
          lblCallStatus.Caption = "Waiting for Callback..."
        Case RASCS_Projected
          lblCallStatus.Caption = "Network Completely Configured."
        Case RASCS_StartAuthentication  ' Windows 95 Only
          lblCallStatus.Caption = "Dialling..."
        Case RASCS_CallbackComplete  ' Windows 95 Only
          lblCallStatus.Caption = "Waiting for Callback..."
        Case RASCS_LogonNetwork  ' Windows 95 Only
          lblCallStatus.Caption = "Logging on to network..."
        Case RASCS_Interactive
          lblCallStatus.Caption = "Interactive"
        Case RASCS_RetryAuthentication
          lblCallStatus.Caption = "Retrying Authentication..."
        Case RASCS_CallbackSetByCaller
          lblCallStatus.Caption = "Callback Set By Caller."
        Case RASCS_PasswordExpired
          lblCallStatus.Caption = "Password Expired."
        Case RASCS_Connected
          lblCallStatus.Caption = "Connected."
          frmRAS.Caption = "Connected to " & strCurrentEntryName
          tmrRAS.Enabled = False
          Unload frmRAS
        Case RASCS_Disconnected
          lblCallStatus.Caption = "Disconnected."
        Case Else
          lblCallStatus.Caption = "Unknown State."
      End Select
      
    Case 10000
      ' Do nothing because RASGetConnectStatus() failed
      
    Case Else
      ' We have an error!
      lngRASErrorNumber = lngRASError
      lblCallStatus.Caption = lpRASError.fnRASErrorMessage()
      
      ' Hang up the connection
      lngRetCode = RasHangUp(hRASConn)
      
      ' Disable the timer
      tmrRAS.Enabled = False
      
      ' Unload the form
      Unload Me
  End Select
End Sub
